<template>
    <div>
        <!--      头部查询部分-->
        <el-row :gutter="4">
            <el-col :span="4">
                <el-autocomplete
                        class="inline-input"
                        prefix-icon="fa fa-search"
                        v-model="keyword.teacherName"
                        :fetch-suggestions="querySearch"
                        placeholder="教师姓名"
                        :trigger-on-focus="false"
                        @keyup.enter.native="initBaseInfo"
                        v-permission="'teacher:base:list'"
                        clearable
                ></el-autocomplete>
            </el-col>
            <el-col :span="4">
                <el-input v-model.trim="keyword.teacherCollegeId" prefix-icon="fa fa-search" placeholder="教工号"
                          v-permission="'teacher:base:list'"
                          @keyup.enter.native="initTeacherBase"></el-input>
            </el-col>
            <el-col :span="2">
                <el-button type="primary" icon="fa fa-search" @click="initTeacherBase"
                           v-permission="'teacher:base:list'"> 搜 索
                </el-button>
            </el-col>
            <el-col :span="2" :offset="2" v-show="false">
                <el-button type="primary" icon="fa fa-angle-double-down" @click="initTeacherBase"
                           v-permission="'teacher:base:list'"> 高 级 搜 索
                </el-button>
            </el-col>
            <el-col :span="2" style="margin-left: 20px">
                <el-button type="primary" icon="fa fa-plus" @click="handleAdd"
                           v-permission="'party:manager:base'"> 添 加 信 息
                </el-button>
            </el-col>
            <el-col :span="2" style="margin-left: 20px">
                <el-button type="danger" icon="fa fa-trash" @click="handleMultipleDelete"
                           v-permission="'teacher:base:delete'"> 删
                    除 多 个
                </el-button>
            </el-col>
            <el-col :span="2" style="margin-left: 20px">
                <el-button type="success" icon="fa fa-download" @click="exportExcel" v-permission="'teacher:base:list'">
                    导 出 Excel
                </el-button>
            </el-col>
            <el-col :span="1" style="margin-left: 20px;">
                <el-button type="warning" icon="fa fa-refresh"
                           v-permission="'teacher:base:list'"
                           @click="refresh">
                </el-button>
            </el-col>
        </el-row>


        <!--    中间表格数据-->

        <el-row>
            <el-col :span="24">
                <el-table width="100%" border :data="page.row">
                    <!--      详情信息              -->
                    <el-table-column prop="teacherName" label="姓名" align="center" width="160" fixed="left"></el-table-column>
                    <el-table-column label="信息管理">
                        <template slot-scope="scope">
                            <el-button @click="viewDetails(scope.row)" type="text" >查看详情</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="teacherDegree" label="学位" align="center" width="160"></el-table-column>
                    <el-table-column prop="teacherDepartment" label="部门" align="center" width="160"></el-table-column>
                    <el-table-column prop="partyIdentity" label="党员状态" align="center" width="160"></el-table-column>
                    <el-table-column label="时间节点" align="center" width="160">
                        <template slot-scope="scope">
                            <el-button v-if="scope.row.partyIdentity==='积极分子'" type="text">
                                {{scope.row.partyActivistsDate}}
                            </el-button>

                            <el-button v-if="scope.row.partyIdentity==='预备党员'" type="text">
                                {{scope.row.partyReallyDate}}
                            </el-button>

                            <el-button v-if="scope.row.partyIdentity==='正式党员'" type="text">
                                {{scope.row.partyConfirmDate}}
                            </el-button>
                        </template>
                    </el-table-column>

                    <el-table-column prop="partyFilesAdrress" label="档案转接地" align="center" width="160"></el-table-column>
                    <el-table-column prop="partyCurrentBranch" label="当前党支部" align="center" width="160"></el-table-column>
                    <el-table-column prop="inPartyRegister" label="入党登记附件" align="center" width="160">
                        <template slot-scope="scope">
                            <el-link v-if="scope.row.inPartyRegister" type="primary"
                                     :href="`${baseURL}${fileViewPath}${scope.row.inPartyRegister}`"
                                     target="_blank">
                                <i class="fa fa-search" aria-hidden="true"></i>
                                {{ scope.row.inPartyRegister | filterFileName }}
                            </el-link>
                        </template>
                    </el-table-column>

                    <el-table-column prop="inPartyRegister" label="入党申请书附件" align="center" width="160">
                        <template slot-scope="scope">
                            <el-link v-if="scope.row.inPartyPetition" type="primary"
                                     :href="`${baseURL}${fileViewPath}${scope.row.inPartyPetition}`"
                                     target="_blank">
                                <i class="fa fa-search" aria-hidden="true"></i>
                                {{ scope.row.inPartyPetition | filterFileName }}
                            </el-link>
                        </template>
                    </el-table-column>

                    <el-table-column prop="inPartyRegister" label="思想汇报附件" align="center" width="160">
                        <template slot-scope="scope">
                            <el-link v-if="scope.row.inPartyReport" type="primary"
                                     :href="`${baseURL}${fileViewPath}${scope.row.inPartyReport}`"
                                     target="_blank">
                                <i class="fa fa-search" aria-hidden="true"></i>
                                {{ scope.row.inPartyReport | filterFileName }}
                            </el-link>
                        </template>
                    </el-table-column>

                    <el-table-column prop="inPartyRegister" label="思想汇报附件" align="center" width="160">
                        <template slot-scope="scope">
                            <el-link v-if="scope.row.inPartyReport" type="primary"
                                     :href="`${baseURL}${fileViewPath}${scope.row.inPartyReport}`"
                                     target="_blank">
                                <i class="fa fa-search" aria-hidden="true"></i>
                                {{ scope.row.inPartyReport | filterFileName }}
                            </el-link>
                        </template>
                    </el-table-column>

                    <el-table-column prop="inPartyActivistsReport" label="入党积极分子附件" align="center" width="160">
                        <template slot-scope="scope">
                            <el-link v-if="scope.row.inPartyActivistsReport" type="primary"
                                     :href="`${baseURL}${fileViewPath}${scope.row.inPartyActivistsReport}`"
                                     target="_blank">
                                <i class="fa fa-search" aria-hidden="true"></i>
                                {{ scope.row.inPartyActivistsReport | filterFileName }}
                            </el-link>
                        </template>
                    </el-table-column>



                    <el-table-column fixed="right" label="操作" width="200px">
                        <template slot-scope="scope">
                            <el-button @click="handleEdit(scope.row)" icon="fa fa-pencil"> 修 改
                            </el-button>
                        </template>
                    </el-table-column>

                </el-table>
            </el-col>
        </el-row>
        <el-dialog
                v-dialog-drag
                :title="isAdd? '新增数据':'修改数据' "
                :visible.sync="centerDialogVisible"
                width="60%"
                center
                @close="resetField"
        >
            <div v-if="isAdd">

                <el-autocomplete
                        class="inline-input"
                        prefix-icon="fa fa-search"
                        v-model="data.teacherName"
                        :fetch-suggestions="querySearch"
                        placeholder="教师姓名"
                        :trigger-on-focus="false"
                        v-permission="'teacher:base:list'"
                        @select="handleSelect"
                        clearable
                ></el-autocomplete>
            </div>
            <div v-else>
                <el-descriptions :column="2" style="margin-left: 18px" size="medium" border>
                    <el-descriptions-item label="姓名">{{data.teacherName}}</el-descriptions-item>
                    <el-descriptions-item label="性别">{{data.teacherGender}}</el-descriptions-item>
                    <el-descriptions-item label="部门">{{data.teacherDepartment}}</el-descriptions-item>
                    <el-descriptions-item label="职称">{{data.teacherRank}}</el-descriptions-item>
                </el-descriptions>
            </div>

            <el-form ref="form" :model="data" label-width="80px" style="margin-top: 20px">
                <el-form-item label="党员类型：" label-width="100px" prop="leaveBeginDate"
                              :label-width="300"
                >
                    <el-select v-model="data.partyIdentity" placeholder="党员类型">
                        <el-option
                                v-for="item in partyIdentitys"
                                :key="item"
                                :label="item"
                                :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item v-if="data.partyIdentity===partyIdentitys[0]" label="积极分子日期"
                              prop="partyActivistsDate"
                              :label-width="300"
                >
                    <el-date-picker
                            v-model="data.partyActivistsDate"
                            type="date"
                            format="yyyy-MM-dd"
                            value-format="yyyy-MM-dd"
                            placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>

                <el-form-item v-if="data.partyIdentity===partyIdentitys[1]" label="预备党员日期"
                              prop="partyReallyDate"
                              :label-width="300"
                >
                    <el-date-picker
                            v-model="data.partyReallyDate"
                            type="date"
                            format="yyyy-MM-dd"
                            value-format="yyyy-MM-dd"
                            placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>

                <el-form-item v-if="data.partyIdentity===partyIdentitys[2]" label="正式党员日期" :label-width="300"
                              prop="partyConfirmDate"
                >
                    <el-date-picker
                            v-model="data.partyConfirmDate"
                            type="date"
                            format="yyyy-MM-dd"
                            value-format="yyyy-MM-dd"
                            placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>

                <el-form-item label="档案转交地" prop="partyFilesAdrress" :label-width="300">
                    <el-input v-model="data.partyFilesAdrress"></el-input>
                </el-form-item>

                <el-form-item label="当前党支部" prop="partyCurrentBranch" :label-width="300">
                    <el-input v-model="data.partyCurrentBranch"></el-input>
                </el-form-item>

                <el-form-item label="入党登记图片:" label-width="auto">
                    <el-upload
                            ref="upload"
                            drag
                            :multiple="false"
                            :limit="1"
                            :headers="fileHeaders"
                            :action="baseURL.concat('file/upload')"
                            name="file"
                            :data="fileDir"
                            :on-success="handleinPartyRegisterRes"
                            :on-error="handleFileUploadError"
                            :show-file-list=true
                            :datasrc="data.inPartyRegister"
                    >
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text"> 拖 拽 或 <em>点 击 上 传 </em></div>
                        <div class="el-upload__tip" slot="tip">建议上传之后浏览 默认不解析 utf-8 以外字符</div>
                    </el-upload>
                </el-form-item>

                <el-form-item label="入党登记:" label-width="auto">
                    <el-link v-if="data.inPartyRegister" :href="`${baseURL}${fileViewPath}${data.inPartyRegister}`"
                             target="_blank">
                        {{ data.inPartyRegister | filterFileName }} <i
                            class="el-icon-view el-icon--right"></i>
                    </el-link>
                    <el-tag v-else type="success"> 无 上 传 文 件</el-tag>
                </el-form-item>


                <el-form-item label="入党申请书:" label-width="auto">
                    <el-upload
                            ref="upload"
                            drag
                            :multiple="false"
                            :limit="1"
                            :headers="fileHeaders"
                            :action="baseURL.concat('file/upload')"
                            name="file"
                            :data="fileDir"
                            :on-success="handleinPartyPetition"
                            :on-error="handleFileUploadError"
                            :show-file-list=true
                    >
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text"> 拖 拽 或 <em>点 击 上 传 </em></div>
                        <div class="el-upload__tip" slot="tip">建议上传之后浏览 默认不解析 utf-8 以外字符</div>
                    </el-upload>
                </el-form-item>

                <el-form-item label="入党申请书:" label-width="auto">
                    <el-link v-if="data.inPartyRegister" :href="`${baseURL}${fileViewPath}${data.inPartyPetition}`"
                             target="_blank">
                        {{ data.inPartyPetition | filterFileName }} <i
                            class="el-icon-view el-icon--right"></i>
                    </el-link>
                    <el-tag v-else type="success"> 无 上 传 文 件</el-tag>
                </el-form-item>


                <el-form-item label="思想汇报:" label-width="auto">
                    <el-upload
                            ref="upload"
                            drag
                            :multiple="false"
                            :limit="1"
                            :headers="fileHeaders"
                            :action="baseURL.concat('file/upload')"
                            name="file"
                            :data="fileDir"
                            :on-success="handleinPartyReport"
                            :on-error="handleFileUploadError"
                            :show-file-list=true
                    >
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text"> 拖 拽 或 <em>点 击 上 传 </em></div>
                        <div class="el-upload__tip" slot="tip">建议上传之后浏览 默认不解析 utf-8 以外字符</div>
                    </el-upload>
                </el-form-item>

                <el-form-item label="思想汇报:" label-width="auto">
                    <el-link v-if="data.inPartyReport" :href="`${baseURL}${fileViewPath}${data.inPartyReport}`"
                             target="_blank">
                        {{ data.inPartyReport | filterFileName }} <i
                            class="el-icon-view el-icon--right"></i>
                    </el-link>
                    <el-tag v-else type="success"> 无 上 传 文 件</el-tag>
                </el-form-item>


                <el-form-item label="入党积极分子报告:" label-width="auto">
                    <el-upload
                            ref="upload"
                            drag
                            :multiple="false"
                            :limit="1"
                            :headers="fileHeaders"
                            :action="baseURL.concat('file/upload')"
                            name="file"
                            :data="fileDir"
                            :on-success="handleinPartyActivistsReport"
                            :on-error="handleFileUploadError"
                            :show-file-list=true
                    >
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text"> 拖 拽 或 <em>点 击 上 传 </em></div>
                        <div class="el-upload__tip" slot="tip">建议上传之后浏览 默认不解析 utf-8 以外字符</div>
                    </el-upload>
                </el-form-item>

                <el-form-item label="入党积极分子报告:" label-width="auto">
                    <el-link v-if="data.inPartyActivistsReport" :href="`${baseURL}${fileViewPath}${data.inPartyActivistsReport}`"
                             target="_blank">
                        {{ data.inPartyActivistsReport | filterFileName }} <i
                            class="el-icon-view el-icon--right"></i>
                    </el-link>
                    <el-tag v-else type="success"> 无 上 传 文 件</el-tag>
                </el-form-item>

                <el-form-item label="正式党员登记:" label-width="auto">
                    <el-upload
                            ref="upload"
                            drag
                            :multiple="false"
                            :limit="1"
                            :headers="fileHeaders"
                            :action="baseURL.concat('file/upload')"
                            name="file"
                            :data="fileDir"
                            :on-success="handleinPartyFormalReport"
                            :on-error="handleFileUploadError"
                            :show-file-list=true
                    >
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text"> 拖 拽 或 <em>点 击 上 传 </em></div>
                        <div class="el-upload__tip" slot="tip">建议上传之后浏览 默认不解析 utf-8 以外字符</div>
                    </el-upload>
                </el-form-item>

                <el-form-item label="正式党员登记:" label-width="auto">
                    <el-link v-if="data.inPartyFormalReport" :href="`${baseURL}${fileViewPath}${data.inPartyFormalReport}`"
                             target="_blank">
                        {{ data.inPartyFormalReport | filterFileName }} <i
                            class="el-icon-view el-icon--right"></i>
                    </el-link>
                    <el-tag v-else type="success"> 无 上 传 文 件</el-tag>
                </el-form-item>

            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="centerDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="changePartyInfo">确 定</el-button>
            </span>
        </el-dialog>

        <!--        详情侧边栏-->
        <el-drawer
                :title="data.teacherName"
                :visible.sync="drawer"
                direction="rtl"
                :before-close="handleDrawerClose"
                append-to-body
                close-on-press-escape
                size="42%"
        >
            <el-descriptions :column="2" style="margin-left: 18px" size="medium" border>
                <el-descriptions-item label="姓名">{{data.teacherName}}</el-descriptions-item>
                <el-descriptions-item label="教工号">{{data.teacherCollegeId}}</el-descriptions-item>
                <el-descriptions-item label="性别">
                    {{ data.teacherGender }}
                    <i :class=" data.teacherGender === '男' ? 'fa fa-male' : 'fa fa-female'"
                       aria-hidden="true" style="font-size: 16px; margin-left: 10px"></i>
                </el-descriptions-item>
                <el-descriptions-item label="部门">{{ data.teacherDepartment }}</el-descriptions-item>
                <el-descriptions-item label="姓名">{{data.teacherName}}</el-descriptions-item>
                <el-descriptions-item v-if="data.partyActivistsDate!=null" label="入党积极分子日期">{{data.teacherCollegeId}}</el-descriptions-item>
                <el-descriptions-item v-if="data.partyReallyDate!=null" label="预备党员日期">{{data.partyReallyDate}}</el-descriptions-item>
                <el-descriptions-item v-if="data.partyConfirmDate!=null" label="正式党员日期">{{data.partyConfirmDate}}</el-descriptions-item>
                <el-descriptions-item label="档案转接地">{{data.partyFilesAdrress}}</el-descriptions-item>
                <el-descriptions-item label="当前党支部">{{data.partyCurrentBranch}}</el-descriptions-item>
                <el-descriptions-item label="入党登记附件">
                    <el-link v-if="data.inPartyRegister" type="primary"
                             :href="`${baseURL}${fileViewPath}${data.inPartyRegister}`"
                             target="_blank">
                        <i class="fa fa-search" aria-hidden="true"></i>
                        {{ data.inPartyRegister | filterFileName }}
                    </el-link>
                </el-descriptions-item>
                <el-descriptions-item label="入党申请书附件">
                    <el-link v-if="data.inPartyPetition" type="primary"
                             :href="`${baseURL}${fileViewPath}${data.inPartyPetition}`"
                             target="_blank">
                        <i class="fa fa-search" aria-hidden="true"></i>
                        {{ data.inPartyPetition | filterFileName }}
                    </el-link>
                </el-descriptions-item>

                <el-descriptions-item v-if="data.inPartyReport!=null" label="思想汇报附件">
                    <el-link v-if="data.inPartyReport" type="primary"
                             :href="`${baseURL}${fileViewPath}${data.inPartyReport}`"
                             target="_blank">
                        <i class="fa fa-search" aria-hidden="true"></i>
                        {{ data.inPartyReport | filterFileName }}
                    </el-link>
                </el-descriptions-item>

                <el-descriptions-item v-if="data.inPartyActivistsReport!=null" label="入党积极分子报告">
                    <el-link v-if="data.inPartyActivistsReport" type="primary"
                             :href="`${baseURL}${fileViewPath}${data.inPartyActivistsReport}`"
                             target="_blank">
                        <i class="fa fa-search" aria-hidden="true"></i>
                        {{ data.inPartyActivistsReport | filterFileName }}
                    </el-link>
                </el-descriptions-item>

                <el-descriptions-item v-if="data.inPartyReallyReport!=null" label="发展预备党员附件">
                    <el-link v-if="data.inPartyReallyReport" type="primary"
                             :href="`${baseURL}${fileViewPath}${data.inPartyReallyReport}`"
                             target="_blank">
                        <i class="fa fa-search" aria-hidden="true"></i>
                        {{ data.inPartyReallyReport | filterFileName }}
                    </el-link>
                </el-descriptions-item>

                <el-descriptions-item v-if="data.inPartyFormalReport!=null" label="正式党员附件">
                    <el-link v-if="data.inPartyFormalReport" type="primary"
                             :href="`${baseURL}${fileViewPath}${data.inPartyFormalReport}`"
                             target="_blank">
                        <i class="fa fa-search" aria-hidden="true"></i>
                        {{ data.inPartyFormalReport | filterFileName }}
                    </el-link>
                </el-descriptions-item>
            </el-descriptions>
        </el-drawer>
    </div>
</template>

<script>
    import {addInfo, getTeacherInfo, page, updateInfo} from "@/api/modules/party";
    import {authKey, baseURL, fileViewPath} from "@/config/constant";
    import {mapState} from "vuex";
    import {removeFile} from "@/api/modules/comprehensive/policy-document";
    import {form, recommendTeacher} from "@/api/modules/dictionary";

    export default {
        name: "PartyBase",
        data(){
            return {
                baseURL, fileViewPath,
                keyword: {
                    teacherName: '',
                    teacherGender: '',
                    teacherDepartment: '',
                    teacherRank: '',


                    id:"",
                    teacherId:"",
                    studentId:"-1",
                    partyIdentity:"",
                    partyActivistsDate:"",
                    partyTargetDate:"",
                    partyReallyDate:"",
                    partyConfirmDate:"",
                    partyFilesAdrress:"",
                    partyCurrentBranch:"",

                    //入党登记
                    inPartyRegister:"",
                    //入党申请书
                    inPartyPetition:"",
                    //思想汇报
                    inPartyReport:"",
                    //入党积极分子报告
                    inPartyActivistsReport:"",
                    //发展预备党员图片
                    inPartyReallyReport:"",
                    //正式党员图片
                    inPartyFormalReport:""
                },
                data:{
                    teacherName: '',
                    teacherGender: '',
                    teacherDepartment: '',
                    teacherRank: '',


                    id:"",
                    teacherId:"",
                    studentId:"-1",
                    partyIdentity:"",
                    partyActivistsDate:"",
                    partyTargetDate:"",
                    partyReallyDate:"",
                    partyConfirmDate:"",
                    partyFilesAdrress:"",
                    partyCurrentBranch:"",

                    //入党登记
                    inPartyRegister:"",
                    //入党申请书
                    inPartyPetition:"",
                    //思想汇报
                    inPartyReport:"",
                    //入党积极分子报告
                    inPartyActivistsReport:"",
                    //发展预备党员图片
                    inPartyReallyReport:"",
                    //正式党员图片
                    inPartyFormalReport:""
                },
                pagination: {
                    current: 1,
                    size: 9
                },
                page: {
                    row: [],
                    total: 0
                },

                // 推荐信息
                recommend: {
                    teacher: [],
                    form: {}
                },

                isAdd:false,
                partyType:"",
                partyTime:"",
                centerDialogVisible:false,
                rules: {
                    teacherName: [{required: true, message: '请输入教师名', trigger: 'blur'}]
                },

                partyIdentitys:["积极分子","预备党员","正式党员"],
                drawer: false
            }
        },

        watch:{
            setPartyType(){
                if (this.data.partyIdentity===this.partyIdentitys[0]){
                    return this.data.partyActivistsDate
                }else if (this.data.partyIdentity===this.partyIdentitys[1]){
                    return this.data.partyReallyDate
                }else {
                    return this.data.partyConfirmDate
                }
            }
        },

        computed:{
            ...mapState("user", ["userToken"]),
            fileHeaders() {
                // 文件上传携带头信息
                let obj = {};
                obj[authKey] = this.userToken;
                return obj
            },
            fileDir() {
                // 上传的文件位置
                return {dir: "policy"}
            }
        },

        filters: {
            filterFileName(value) {
                // 斜杠位置
                let slashIndex = value.lastIndexOf("/");
                // 文件随机数位置
                let randomIndex = value.indexOf("-");
                return value.slice(slashIndex + 1, randomIndex) + value.slice(value.indexOf('.'));
            }
        },
        methods:{

            initRecommend() {
                recommendTeacher().then(response => {
                    this.recommend.teacher = response;
                });
                form().then(response => {
                    this.recommend.form = response;
                });
            },

            // 查询
            querySearch(queryString, cb) {
                cb(this.recommend.teacher.filter(item => item.value.indexOf(queryString) !== -1))
            },

            //选择结果
            handleSelect(item){
                this.data.teacherId=item.id;
                alert(this.data.teacherId)
            },

            handleDrawerClose() {
                this.drawer = false;
                this.$refs.form.resetFields();
            },

            initBaseInfo() {
                page(this.pagination, this.keyword).then(response => {
                    this.page.row = response.row;
                    this.page.total = response.total;
                })
            },

            async handleinPartyRegisterRes(response) {
                await removeFile(this.data.inPartyRegister);

                if (response.code <= 30000 && response.code >= 20000) {
                    this.data.inPartyRegister=response.data
                    this.$message.success({message: response.msg})
                } else {
                    this.$message.error({message: response.msg})
                }
            },

            async handleinPartyPetition(response) {
                await removeFile(this.data.inPartyPetition);

                if (response.code <= 30000 && response.code >= 20000) {
                    this.data.inPartyPetition=response.data
                    this.$message.success({message: response.msg})
                } else {
                    this.$message.error({message: response.msg})
                }
            },

            async handleinPartyReport(response) {
                await removeFile(this.data.inPartyReport);

                if (response.code <= 30000 && response.code >= 20000) {
                    this.data.inPartyReport=response.data
                    this.$message.success({message: response.msg})
                } else {
                    this.$message.error({message: response.msg})
                }
            },

            async handleinPartyActivistsReport(response) {
                await removeFile(this.data.inPartyActivistsReport);

                if (response.code <= 30000 && response.code >= 20000) {
                    this.data.inPartyActivistsReport=response.data
                    this.$message.success({message: response.msg})
                } else {
                    this.$message.error({message: response.msg})
                }
            },

            async handleinPartyFormalReport(response) {
                await removeFile(this.data.inPartyFormalReport);

                if (response.code <= 30000 && response.code >= 20000) {
                    this.data.inPartyFormalReport=response.data
                    this.$message.success({message: response.msg})
                } else {
                    this.$message.error({message: response.msg})
                }
            },


            handleFileUploadError() {
                this.$message.error({message: "上传失败"})
            },

            handleAdd() {
                this.isAdd=true
                Object.assign(this.data, {
                    id:"",
                    teacherId:"",
                    studentId:"-1",
                    partyIdentity:"",
                    partyActivistsDate:"",
                    partyTargetDate:"",
                    partyReallyDate:"",
                    partyConfirmDate:"",
                    partyFilesAdrress:"",
                    partyCurrentBranch:"",
                });
                this.centerDialogVisible = true;
            },

            // 修改单个
            handleEdit(row) {
                // 不是添加
                this.isAdd = false;
                Object.assign(this.data, row);
                this.centerDialogVisible = true;
            },

            viewDetails(info){

                Object.assign(this.data, {
                    teacherName: '',
                    teacherGender: '',
                    teacherDepartment: '',
                    teacherRank: '',


                    id:"",
                    teacherId:"",
                    studentId:"-1",
                    partyIdentity:"",
                    partyActivistsDate:"",
                    partyTargetDate:"",
                    partyReallyDate:"",
                    partyConfirmDate:"",
                    partyFilesAdrress:"",
                    partyCurrentBranch:"",

                    //入党登记
                    inPartyRegister:null,
                    //入党申请书
                    inPartyPetition:null,
                    //思想汇报
                    inPartyReport:null,
                    //入党积极分子报告
                    inPartyActivistsReport:null,
                    //发展预备党员图片
                    inPartyReallyReport:null,
                    //正式党员图片
                    inPartyFormalReport:null
                });
                Object.assign(this.data, info);
                this.drawer=true
            },
            resetField() {
                // 清空表单验证
                this.$refs.form.resetFields();
            },

            //设置图片的全路径
            setImageSrc(image){
                let imageSrc=baseURL+fileViewPath+image
                return imageSrc
            },

            //修改信息
            changePartyInfo(){
                if (this.isAdd){
                    addInfo(this.data).then(()=>{
                        this.centerDialogVisible = false
                        this.initBaseInfo()
                    })
                }else {
                    updateInfo(this.data).then(()=>{
                        this.centerDialogVisible = false
                        this.initBaseInfo()
                    })
                }

            },
            //获取所有教师信息
            initTeacherBase() {
                getTeacherInfo(this.pagination, this.keyword).then(response => {
                    this.page.row = response.row;
                    this.page.total = response.total;
                })
            },
        },
        mounted() {
            this.initBaseInfo()
            this.initRecommend()
        }
    }
</script>

<style scoped>

</style>